package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/31 17:07
 **/
public class Day46_6_Offer28_IsSymmetric {
    class Solution {
        public boolean isSymmetric(TreeNode root) {
            if(root == null) return true;
            return dfs(root.left, root.right);
        }
        private boolean dfs(TreeNode left, TreeNode right){
            if(left == null && right == null) return true;
            if(left == null || right == null) return false;

            return left.val == right.val && dfs(left.left, right.right) && dfs(left.right, right.left);
        }
    }
}